﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using CSDL_NC_07.DAO;
using CSDL_NC_07.BUS;
using System.Data.SqlClient;

namespace CSDL_NC_07.GUI.other
{
    public partial class MHXemTieuSuBenh : UserControl
    {
        public MHXemTieuSuBenh()
        {
            InitializeComponent();
        }

        private void MHXemTieuSuBenh_Load(object sender, EventArgs e)
        {
            txtMaBenhNhan.Focus();
        }

        private void txtMaBenhNhan_Click(object sender, EventArgs e)
        {
            txtMaBenhNhan.Text = "";
        }

        private void btnKiemTra_Click(object sender, EventArgs e)
        {
            if (txtMaBenhNhan.Text.Length != 12){
                MessageBox.Show("Mã bệnh nhân không hợp lệ.");
                return;
            }

            DataProvider dataProvider = new DataProvider();

            List<SqlParameter> parameterList = new List<SqlParameter>();
            parameterList.Add(new SqlParameter("MaBenhNhan", txtMaBenhNhan.Text));

            if (!dataProvider.IsConnect())
                dataProvider.Connect();

            DataSet ds = dataProvider.ExcuteProcedureGetDataSet("usp_TieuSuBenh6ThangGanDay", parameterList.ToArray());
            dataProvider.Disconnect();

            gViewDichVu.DataSource = ds.Tables[1];
            gViewTieuSu.DataSource = ds.Tables[0];
        }
    }
}
